package recommendation;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;

import hibernate.method.GameMethods;
import hibernate.model.GamesRate;
import hibernate.util.HibernateUtil;

import org.hibernate.Session;
import org.hibernate.SessionFactory;

public class DataGiver {
	
	public static void getAllGamesRatings () throws IOException{
		SessionFactory sessionFactory = HibernateUtil.getSessionAnnotationFactory();
		Session session= sessionFactory.openSession();
		session.beginTransaction();
		
		GameMethods gm = new GameMethods();
		List<GamesRate> list = gm.listAllGamesRates(sessionFactory, session);
		BufferedWriter bw = new BufferedWriter(new FileWriter("recommendationData/gamesTemp.csv"));
		
		for (GamesRate g: list){
			bw.write(g.getUser_id() + "," + g.getGame_id() + "," + g.getRate() + "\n");
		}
		bw.close();
		
	}

	public static void main (String [] args) throws IOException{
		getAllGamesRatings();
	}

}
